import Echarts from './Components/echarts.tsx'
import Data from './Components/data.tsx'
import Table from './Components/table.tsx'
import { getHomeApi } from '@/api/home'
import { useEffect, useState } from 'react'
type StatisticItem = {
    title: string
    value: number
    precision: number
    valueStyle: { color: string }
    prefix: 'up' | 'down'
    suffix: string
}
export default function Home() {
    const [data, setData] = useState<StatisticItem[]>([])
    const [echartsData, setEchartsData] = useState([])
    const [queryData, setQueryData] = useState<any[]>([])

    useEffect(() => {
        getHomeApi().then((res: any) => {
            console.log('Home API Response:', res)
            if (!res) return
            setData(res.data)
            setEchartsData(res.echartData || [])
            setQueryData(res.queryData.data || [])
        })
    }, [])
    return (
        <>
            <Data BaseData={data} />
            <Echarts EchartData={echartsData} />
            <Table QueryData={queryData} />
        </>
    )
}
